
 <template>
    <div class="login-container">
      <!-- <el-button @click="exportToExcel">导出</el-button> -->
       <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="名字" prop="name">
          <el-select v-model="queryParams.name" placeholder="请输入患者名字" clearable size="small">
              <el-option v-for="item in patients" :key="item.name" :label="item.text" :value="item.name" />

          </el-select>
      </el-form-item>
    
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="patients">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="编号" align="center" prop="registrationId" />
      <el-table-column label="患者id" align="center" prop="name" />
      <el-table-column label="医生id" align="center" prop="trueName" />
      <el-table-column label="操作员id" align="center" prop="cookie" />
      <el-table-column label="诊所id" align="center" prop="hospitalName" />
      <el-table-column label="科室id" align="center" prop="departmentName" />
      <el-table-column label="挂号费用id" align="center" prop="registeredfeeId" />
      <el-table-column label="挂号总金额" align="center" prop="registrationAmount" />
      <el-table-column label="挂号编号" align="center" prop="registrationNumber" />
      <el-table-column label="挂号状态" align="center" prop="registrationStatus" />
      <el-table-column label="排版主表id" align="center" prop="schedulingId" />
      <el-table-column label="排版时段表id" align="center" prop="schedulingSubsectionId" />
      <el-table-column label="排版星期表id" align="center" prop="schedulingWeekId" />

      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="更新时间" align="center" prop="updateTime" />
      <el-table-column label="收费总表" align="center" prop="pkgId" />
     <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <template v-if="scope.row.registrationStatus == '1'">
            <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >付款</el-button>
          </template>
           <template v-if="scope.row.registrationStatus == '2'">
            <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handlebutton1"
          >已付款</el-button>
          </template>
        </template>
         <!-- v-if="patients.isDel === 0?'true':'false'" -->
         <!-- v-if="handleUpdate1" -->
      </el-table-column>
      <el-table-column label="状态" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <template v-if="scope.row.registrationStatus == '2'">
            <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handledel(scope.row)"
          >退费</el-button>
          </template>
        </template>
      </el-table-column>

  <el-table-column label="是否作废" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
           <template v-if="scope.row.registrationStatus == '4'">
            <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="dels1"
          >已作废</el-button>
          </template>
          <template v-else>
            <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="dels(scope.row)"
          >作废</el-button>
          </template>
        </template>
        
        
      </el-table-column>

    </el-table>
  <el-dialog title="备注" :visible.sync="open"  width="35%" append-to-body>
        <el-form ref="form" :model="rowlList" :rules="rules" label-width="80px">
            <el-row>
                <el-col :span="18" :offset="2">

                    <el-form-item label="备注" prop="admMemo">
                        <el-input v-model="rowlList.admMemo"></el-input>
                    </el-form-item>

                </el-col>
            </el-row>

        </el-form>
        <div slot="footer" class="dialog-footer">
        
        <el-button type="primary" @click="submitForm()">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
       
      </div>
    </el-dialog>
   


      <el-row>
          <el-col style="text-align: right">
              <el-pagination @size-change="handleSizechange"
              @current-change="handleCurrentChange"
              :current-page="currentpage"
              :page-sizes="[5,10,50,100]"
              :page-size="pagesize"
              layout="total,sizes,prev,pager,next,jumper"
              :total="total"
               >
              </el-pagination>

          </el-col>

      </el-row>
   </div>

</template>

 <script>
  import {reg_cx,reg_xg,reg_tf,reg_xgzt} from "@/api/jjs/dzmregistration";
export default {
  name: "Inspect",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 质量巡检表格数据
      patients: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
       // 用户基本信息
      user:null,
      currentpage:1,
      pagesize:10,
      ticket:[],
      // handledel1:true,
      // handleUpdate1:true,
     //退费行的值
      rowlList:{},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
         name:null
        //  pId: null,
        // checkPart: null,
        // qualityerId: null,
        // checkSituation: null,
        // corretivePreventiveMeasure: null,
        // comment: null,
        // attacheIds: null,
        // checkDate: null,
        // updateUser: null

      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    // this.getList();
     console.log("创建时");
      this.getpatient();
     // this.getMedicinesList();
     

  },
  methods: {
    // getList() {
    //    console.log("调用list");

    // },
       cancel() {
      this.open = false;
    //   this.reset();
    },

      //表单重置
      reset() {
      this.form = {
       
        name: null
      };
      this.resetForm("form");
    },
      /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getpatient();
    },
        /** 重置按钮操作 */
    resetQuery() {
       this.queryParams.name=null;
      this.handleQuery();
    },
    getpatient(){
      //  this.loading = true;
      // listInfo(this.queryParams).then(response => {
      //   debugger
      //   this.infoList = response.rows;

      //   this.total = response.total;
      //   this.loading = false;
      // });
      reg_cx(this.queryParams).then(response=>{
        console.log(this.queryParams+"yyyyyyyy");
          //  this.patients=response.data;
          // console.log(this.patients.name+"这是patient");
            // this.total = response.total;
        // this.loading = false;
         if(response.code ===200){
              this.ticket=response.data;
              console.log(this.patients.name+"这是patient");
              this.total=response.data.length;
              this.getPageInfo();
              this.$message({
                message:"数据加载成功",
                type:"success",
              });

           } else{
             this.$message({
               message:"数据加载失败",
               type:"error",
             });

           }
      })


    },

    getPageInfo(){
      this.patients=[];
      for(let i=(this.currentpage-1)*this.pagesize;i<this.total;i++){
          this.patients.push(this.ticket[i]);
          if(this.patients.length === this.pagesize) break;
      }
    },
    handleSizechange(size){
      this.pagesize=size;
      this.getPageInfo();
    },
    handleCurrentChange(pageNumber){
      this.currentpage=pageNumber;
      this.getPageInfo();
    },
    //xiugai


     handleUpdate(row) {
      console.log(row);     
      //this.reset();
      // const patientId = row.patientId || this.ids;
      console.log();
      reg_xg(row).then(response => {
          console.log(response);
        // this.form = response.data;
        // this.open = true;
        // this.title = "修改患者库";

         alert("提交成功");
        this.open = false;
        this.getpatient();
      });
       
    },
    handlebutton1(){
        alert("已经就诊");
    },
     dels1(){
        alert("已作废");
    },

     submitForm(row) {

            reg_tf(this.rowlList).then(response => {
                console.log(response+"yllll")
            //   this.$modal.msgSuccess("修改成功");
            alert("修改成功");
               this.open = false;
              this.getpatient();
            });
    },
     handledel(row) {
            this.rowlList=row;
            //  reg_tf(row).then(response => {
            //     console.log(response+"yllll")
            // //   this.$modal.msgSuccess("修改成功");
            // alert("修改成功");
            //   //  this.open = false;
            //   this.getpatient();
            // });

              this.open = true;
             this.title = "添加质量巡检";
    },

      dels(row) {
      // console.log(status);
      // console.log(row)
      // const patientId = row.patientId || this.ids;
      // console.log(patientId);
                // console.log(row.isDel);
              //  this.handleUpdate1=false;
                reg_xgzt(row).then(response => {

                 console.log(response)
            //   this.$modal.msgSuccess("修改成功");
            alert("修改成功");
              // this.open = false;
              this.getpatient();
            });


    },
  
   },
};
</script>
